<template>
  <div class="user-dialog">
    <el-dialog :title="formTitle" :visible.sync="visible" height="700px" width="80%" :close-on-click-modal=false
               @close="dialogClose">
      <el-form ref="userForm111" :model="dataForm" :label-width="formLabelWidth">
        <el-form-item label="企业名称">
          <el-input v-model="dataForm.enterprise_name"></el-input>
        </el-form-item>
        <el-form-item label="联系人员">
          <el-input v-model="dataForm.contact_person"></el-input>
        </el-form-item>
        <el-form-item label="联系电话">
          <el-input v-model="dataForm.contact_phone_number"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer">
        <el-button @click="reset">重 置</el-button>
        <el-button type="primary" @click="submit">确 定</el-button>
      </div>
    </el-dialog>

  </div>

</template>

<script>


  export default {
    name: "index",
    methods: {
      setForm(rowForm) {
        this.visible = true;
        if (rowForm) {
          rowForm['action_type'] = 'enterpriseUpdate';
          this.dataForm = rowForm;
          this.formTitle='修改';
        } else {
          this.dataForm['action_type'] = 'enterpriseAdd';
          this.formTitle='添加';
        }
      },
      reset() {
        this.dataForm = {
          enterprise_name_id: null,
          enterprise_name: null,
          contact_person: null,
          contact_phone_number: null
        };
      },
      submit() {
        let me = this;
        this.$axios.post('enterpriseRoutes',me.dataForm).then(function () {
          me.visible = false;
          //刷新
          me.$parent.queryData();
        });
      },
      dialogClose() {
        this.reset();
      }
    },
    data() {
      return {
        dataForm: {
          enterprise_name_id: null,
          enterprise_name: null,
          contact_person: null,
          contact_phone_number: null
        },
        visible: false,
        formTitle: '111',
        formLabelWidth: '120px'
      }
    }
  }
</script>

<style lang="scss">
  .user-dialog {
    .el-dialog__header {
      padding: 20px 20px 10px;
      background-color: #40c9c6;
    }
    .el-dialog__title {
      line-height: 24px;
      font-size: 18px;
      text-align: left;
      font-weight: bold;
      color: #f1fdff;
    }
  }
</style>
